package mapred.task.example;

import java.io.IOException;
import java.util.Iterator;

import mapred.task.extention.TextReducer;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;

public class DoubleSum_TextReducer extends TextReducer {

    @Override
    public void reduce(Text key, Iterator<Text> values,
            OutputCollector<Text, Text> output, Reporter reporter)
            throws IOException {
        double sum = 0;
        while (values.hasNext()) {
            sum += Double.parseDouble(values.next().toString());
        }
        output.collect(key, new Text(String.valueOf(sum)));
    }

    @Override
    protected void setUp() {
    }

}
